package br.com.array.android.ma.old;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.LinearLayout;
import br.com.array.android.ma.R;
import br.com.array.android.ma.view.DemandaFragment;
import br.com.array.android.ma.view.EnergiaReativaFragment;
import br.com.array.android.ma.view.FatorPotenciaFragment;
import br.com.array.android.ma.view.PagesFragment;

/**
 * Created by leonardo.neves on 09/05/2014.
 *
 */
public class PrincipalActivity extends FragmentActivity {

    private EnergiaReativaFragment energiaReativaFragment;
    private DemandaFragment demandaFragment;
    private FatorPotenciaFragment fatorPotenciaFragment;
    private int posicao = 0;


    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.principal_activity);

        posicao = getIntent().getIntExtra("posicao", posicao);

        LinearLayout view = (LinearLayout) findViewById(R.id.root);
        PagesFragment pagesFragment = new PagesFragment(getSupportFragmentManager(), this);
        energiaReativaFragment = new EnergiaReativaFragment();
        demandaFragment = new DemandaFragment();
        fatorPotenciaFragment = new FatorPotenciaFragment();
        pagesFragment.setFragmentPages(energiaReativaFragment, demandaFragment, fatorPotenciaFragment);

        pagesFragment.setCurrentItem(posicao);

        view.addView(pagesFragment);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_principal, menu);
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()){
            case R.id.menuPrincipal:

                /*AlertDialog.Builder builder = new AlertDialog.Builder(PrincipalActivity.this);
                final NumberPicker picker = new NumberPicker(getApplicationContext());
                picker.setMinValue(1);
                picker.setMaxValue(60);
                builder.setTitle("Configurar alarme");
                builder.setView(picker);
                builder.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                    }
                }).setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
//                        energiaReativaView.setTempo(Long.valueOf(picker.getValue() * 60000));
                    }
                });
                builder.show();*/
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }
}